#拿bilibili做个测试，测一下循环多少次可以获取到新页面上的内容
from selenium import webdriver
from selenium.webdriver.common.by import By
import time


wd = webdriver.Chrome()


wd.get('https://www.bilibili.com')

timestart = time.time()
element = wd.find_element(By.CLASS_NAME,'nav-search-input')
element.send_keys('python自动化\n')

timeend = time.time()
runtime = timeend - timestart
print(runtime)#发现是0.6秒


i = 0

while True:
    try:
        element = wd.find_element(By.CLASS_NAME,'search-input-el')
        element.send_keys('王者荣耀\n')
        break

    except:
        i = i+1
        print(i)

#这个i就是记录了从发送python自动化到成功找到nav-input-el并成功发送王者荣耀的这个过程的循环次数

#让进程一直运行下去
input()